﻿@using ECG.Utility
@using ECG.WebUI.CustomHelpers
@model List<ECG.Common.ProductRateByCateTopListPagingDto>

<input type="hidden" name="hidRatePagging" class="hidRatePagging" value="" iTotalPage="@ViewBag.TotalPage" iCate="@ViewBag.Category" iCurrentPage="@ViewBag.CurrentPage"/>
@if (Model.Any())
{
    foreach (var item in Model)
    {
        var pDetailLink = Url.Action("Index", "ProductDetail", new {productId = item.Id, productName = StringUtil.RemoveSpecialCharactersVn(item.Name)});
        <li>
            <div class="pItem">
                @if (item.CreateDate >= DateTime.Now)
                {
                    <i class="icon-cate-new">MỚI</i>
                }
                <a href="@pDetailLink" class="pItem-lnkImg">

                    @if (item.DiscountPercentage > 0)
                    {
                        <span class="pItem-per">-@item.DiscountPercentage.ToString("#.#")<i>%</i></span>
                    }
                    <img src="@item.ImagePath.ImagePathThumb(135, 135)" width="135" height="135" alt="@item.Name" class="lzLoading" />
                </a>
                <div class="pItem-info">
                    <h2>
                        <a href="@pDetailLink">@item.Name</a>
                    </h2>
                    @if (item.PromotionPrice > 0)
                    {
                        <p class="pItem-PriceOld">
                            @item.Price.ToString("##,###,###") đ
                        </p>
                        <p class="pItem-PriceNew">
                            @item.PromotionPrice.ToString("##,###,###") <strong>đ</strong>
                        </p>
                    }
                    else
                    {
                        <p class="pItem-PriceNew">
                            @item.Price.ToString("##,###,###") <strong>đ</strong>
                        </p>
                    }
                    <p style="line-height: 13px; margin-top: 6px;">
                        @{
                            string StarPercent = "0";
                            if (item.AverageRate > 0)
                            {
                                StarPercent = (Convert.ToDouble(item.AverageRate)*100/5).ToString("#.#").Replace(',', '.');
                            }
                        }
                        <span class="itm-ratStars inlineBlocka"><span style="width: @StarPercent%;" class="itm-ratStars itm-ratRating"></span></span>
                    </p>
                </div>
            </div>
        </li>
    }
}
